var app = getApp()
Page({
  data: {
    content: "",
    imgUrl: "",
    isShow: false
  },
  onLoad: function (options) {
    console.log("options.content=="+options.content)
    var contentArray = decodeURIComponent(options.content)
    var contentObj = JSON.parse(contentArray)
    var content = ""
    for (var i = 0; i < contentObj.length; i++) {
      content = content + contentObj[i].words
    }
    var imgUrl = options.url
    this.setData({
      imgUrl: imgUrl,
      content: content
    })

  },
  onOcr: function () {
    tt.switchTab({
      url: '/pages/index/index'
    });
  },
  onCopy: function () {
    if (this.data.content == null || this.data.content == "") {
      app.showToastMsg("复制内容为空！")
      return
    }
    tt.setClipboardData({
      data: this.data.content,
      success(res) {
        app.showToastMsg("复制成功！")
      },
      fail(res) {
        console.log(`setClipboardData调用失败`);
      }
    });
  },
  onShare: function () {
    this.setData({
      isShow: true
    })
  },
  hideModal: function () {
    this.setData({
      isShow: false
    })
  },
  onShareAppMessage(option) {
    if (this.data.content == null || this.data.content == "") {
      app.showToastMsg("转发内容为空！")
      return
    }
    return {
      title: '识别的内容',
      desc:
        this.data.content,
      path: '/pages/index/index',
    }
  },
})